@echo off
chcp 65001 >nul

echo === MQ学习项目 Docker启动脚本 ===

REM 检查Docker是否运行
docker info >nul 2>&1
if errorlevel 1 (
    echo 错误: Docker未运行，请先启动Docker
    pause
    exit /b 1
)

REM 检查Docker Compose是否可用
docker-compose --version >nul 2>&1
if errorlevel 1 (
    echo 错误: Docker Compose未安装，请先安装Docker Compose
    pause
    exit /b 1
)

echo Starting all MQ services and Spring Boot applications...

REM Stop and remove existing containers
echo Cleaning existing containers...
docker-compose down

REM Build and start all services
echo Building and starting all services...
docker-compose up -d --build

REM Wait for services to start
echo Waiting for services to start...
timeout /t 30 /nobreak >nul

REM Check service status
echo Checking service status...
docker-compose ps

echo.
echo.
echo === Service Access URLs ===
echo RabbitMQ Management: http://localhost:15672 (admin/admin123)
echo ActiveMQ Management: http://localhost:8161 (admin/admin123)
echo Pulsar Management: http://localhost:8080
echo.
echo === Spring Boot Application URLs ===
echo RabbitMQ App: http://localhost:8081
echo Kafka App: http://localhost:8082
echo RocketMQ App: http://localhost:8083
echo ActiveMQ App: http://localhost:8084
echo Pulsar App: http://localhost:8085
echo.
echo === Test Commands ===
echo Test RabbitMQ: curl -X POST http://localhost:8081/rabbitmq/send/direct
echo Test Kafka: curl -X POST http://localhost:8082/kafka/send/test
echo Test RocketMQ: curl -X POST http://localhost:8083/rocketmq/send/sync
echo Test ActiveMQ: curl -X POST http://localhost:8084/activemq/send/queue
echo Test Pulsar: curl -X POST http://localhost:8085/pulsar/send/sync
echo.
echo === Stop Services ===
echo Run 'docker-compose down' to stop all services
echo Run 'docker-compose down -v' to stop services and remove volumes

pause 